/*
 *  dna_eintpoll.h -- provide dna-system external input interrupt polling implementation.
 *  If the CPU's external input interruption resources insufficient, then we can be solved by polling.
 *
 *  #############################
 *  Pin define: please refer to the dna_gpio.h :-)
 *  #############################
 *
 *  ORIGINAL AUTHOR: Xu Chun (chun.xu@broadlink.com.cn)
 *
 *  Copyright (c) 2016 Broadlink Corporation
 */

#ifndef __DNA_EINTPOLL_H
#define __DNA_EINTPOLL_H

/**
 * @brief This function is mainly used to initialize GPIO external interrupt polling framework.
 * @param[in] none.
 * @return    To indicate whether this function call success or not. 
 *            If the return value is #DNA_SUCCESS, it means success, otherwise means fail.
 * @warning
 */
int dna_eint_poll_init(void);

/**
 * @brief This function is mainly used to deinitialize GPIO external interrupt polling framework.
 * @param[in] none.
 * @return    To indicate whether this function call success or not. 
 *            If the return value is #DNA_SUCCESS, it means success, otherwise means fail.
 * @warning
 */
int dna_eint_poll_deinit(void);

/**
 * @brief This function is mainly used to register and enable GPIO external interrupt.
 * @param[in] pin specifies pin number to initialize.
 * @param[in] mode specifies interrupt trigger mode.
 * @param[in] callback is the function given by user, which will be called at EINT ISR routine.
 * @param[in] data is a reserved parameter for user,it will push to callback.
 * @return    To indicate whether this function call success or not. 
 *            If the return value is #DNA_GPIO_STATUS_OK, it means success;
 *            If the return value is #DNA_GPIO_STATUS_INVALID_PARAMETER, it means a wrong parameter(except for pin number) is given, the parameter must be verified;
 *            If the return value is #DNA_GPIO_STATUS_ERROR_PIN, it means a wrong pin number is given, the parameter must be verified;
 *            If the return value is #DNA_GPIO_STATUS_ERROR, it means failure.
 * @warning
 */
int dna_eint_poll_register(int pin, int mode,
    void (* callback)(void * data), void * data);

/**
 * @brief This function is mainly used to unregister and disable GPIO external interrupt.
 * @param[in] pin specifies pin number to unregister.
 * @return    To indicate whether this function call success or not. 
 *            If the return value is #DNA_GPIO_STATUS_OK, it means success;
 *            If the return value is #DNA_GPIO_STATUS_INVALID_PARAMETER, it means a wrong parameter(except for pin number) is given, the parameter must be verified;
 *            If the return value is #DNA_GPIO_STATUS_ERROR_PIN, it means a wrong pin number is given, the parameter must be verified;
 *            If the return value is #DNA_GPIO_STATUS_ERROR, it means failure.
 * @warning
 */
int dna_eint_poll_unregister(int pin);

#endif

